import './piece.css';
interface PieceProps {
    position: {
        column: number;
        row: number;
    };
    showTar: null | 'X' | 'O';
    checkedEffect: (res: ClickPieceData) => void;
}
/**
 * @function Piece 棋子hook
 * @param {PieceProps} props props数据
 * @returns Piece hook
 */
export default function Piece (props: PieceProps) {
    const { checkedEffect, position, showTar } = props;
    /**
     * @function clickPiece 处理点击棋子按钮事件
     * @returns {void}
     */
    function clickPiece (): void {
        if (showTar) {
            return;
        }
        checkedEffect({ column: position.column, row: position.row });
    }
    console.log('update');
    return (
        <button className="piece" onClick={clickPiece}>{showTar ? showTar : ' '}</button>
    );
}
